package cn.dw.utils;

import com.google.gson.Gson;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletResponse;

public class ResultUtils
{
  public static void toJson(HttpServletResponse respones, Object data)
    throws IOException
  {
    Gson gson = new Gson();
    String result = gson.toJson(data);
    respones.setCharacterEncoding("text/json; charset=utf-8");
    respones.setHeader("Cache-Control", "no-cache");
    PrintWriter out = respones.getWriter();
    out.print(result);
    out.flush();
    out.close();
  }
}
